package com.ruiysoft.crm.controller;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.ruiysoft.crm.dto.CourseEx;
import com.ruiysoft.crm.entity.Course;
import com.ruiysoft.crm.entity.SysEmployee;
import com.ruiysoft.crm.mapper.CourseMapper;
import com.ruiysoft.crm.mapper.SysEmployeeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Yanghu
 * @since 2018-08-20
 */
@RestController
@RequestMapping("employee")
public class SysEmployeeController {
    @Autowired
    SysEmployeeMapper sysEmployeeMapper;

    @Cacheable("query")
    @GetMapping("query")
    public Object query() {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("success", false);

        try {
            EntityWrapper<SysEmployee> entityWrapper = new EntityWrapper();
            entityWrapper.orderBy("createTime", false);
            List<SysEmployee> list = sysEmployeeMapper.selectPage(new Page<Course>(1, 25), entityWrapper);
            if(list.size() > 0) {
                map.put("success", true);
                map.put("data", list);
            }
            else
                map.put("errorMsg", "查询数据失败");

        } catch (Exception error) {
            map.put("errorMsg", "delete 异常: " + error.getMessage());
        }

        return map;
    }


}
